package cn.itcast.crm.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import cn.itcast.crm.domain.Customer;

@Repository
public interface ICustomerDao extends JpaRepository<Customer, Integer>{
	public List<Customer> findByFixedAreaIdIsNull();
	public List<Customer> findByFixedAreaId(String fixedAreaId);

	@Query("update Customer set fixedAreaId = ? WHERE id = ?")
	@Modifying
	public void updateFixedAreaId(String fixedAreid, Integer id);
	public Customer findByTelephone(String telephone);
	
	@Query("update Customer set type=1 WHERE telephone = ?")
	@Modifying
	public void updateType(String telephone);
	
	public Customer findByTelephoneAndPassword(String telephone, String password);
	
	@Query("select fixedAreaId from Customer WHERE address = ?")
	public String findFixedAreaIdByAddress(String address);
}
